package com.koron.order.linepatrol.check.controller;


import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.config.ThreadLocalContext;
import com.koron.order.linepatrol.check.bean.dto.LinePatrolCheckSatelliteDTO;
import com.koron.order.linepatrol.check.bean.po.LinePatrolCheckSatellite;
import com.koron.order.linepatrol.check.bean.query.LinePatrolCheckSatelliteQuery;
import com.koron.order.linepatrol.check.bean.vo.LinePatrolCheckSatelliteVO;
import com.koron.order.linepatrol.check.service.LinePatrolCheckSatelliteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 卫星巡视风险核实工单(LinePatrolCheckSatellite)表控制层
 *
 * @author jzp
 * @since 2023-02-08 10:25:50
 */
@Api(tags = "线路巡视-风险核实工单接口")
@RestController
@RequestMapping("linePatrolSatelliteCheck")
public class LinePatrolCheckSatelliteController {
    /**
     * 服务对象
     */
    @Autowired
    private LinePatrolCheckSatelliteService linePatrolCheckSatelliteService;

    private String getCurrDs() {
        return ThreadLocalContext.get().getCurrDs();
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "根据id查询")
    @GetMapping
    public Response<LinePatrolCheckSatelliteVO> selectOne(@RequestParam String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolCheckSatelliteService, "getVoById", LinePatrolCheckSatelliteVO.class, id));
    }

    @ApiOperation(value = "根据id查询详情")
    @GetMapping("detail")
    public Response<LinePatrolCheckSatelliteDTO> selectOneDetail(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolCheckSatelliteService, "getDtoById", LinePatrolCheckSatelliteDTO.class, id));
    }

    @ApiOperation(value = "分页查询")
    @GetMapping("page")
    public Response<PageInfo<LinePatrolCheckSatelliteVO>> page(PageQuery pageQuery, LinePatrolCheckSatelliteQuery query) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), linePatrolCheckSatelliteService, "page", PageInfo.class, pageQuery, query));
    }

    @ApiOperation(value = "保存")
    @PostMapping("save")
    public Response<LinePatrolCheckSatelliteVO> save(@RequestBody LinePatrolCheckSatelliteVO linePatrolCheckSatelliteVO) {
        ADOConnection.runTask(getCurrDs(), linePatrolCheckSatelliteService, "saveVo", Boolean.class, linePatrolCheckSatelliteVO);
        return Response.ok(linePatrolCheckSatelliteVO);
    }

    @ApiOperation(value = "更新")
    @PutMapping("update")
    public Response<LinePatrolCheckSatellite> update(@RequestBody LinePatrolCheckSatellite linePatrolCheckSatellite) {
        ADOConnection.runTask(getCurrDs(), linePatrolCheckSatelliteService, "update", Boolean.class, linePatrolCheckSatellite);
        return Response.ok(linePatrolCheckSatellite);
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("delete")
    public Response delete(@RequestParam String id) {
        ADOConnection.runTask(getCurrDs(), linePatrolCheckSatelliteService, "deleteById", Boolean.class, id);
        return Response.ok();
    }

}

